using XLua;
using UnityEngine;

public class EventManager
{
    private static LuaTable s_Event;
    private static LuaFunction s_DispatchEvent;
    private static LuaFunction dispatchEvent
    {
        get
        {
            if (s_DispatchEvent == null)
            {
                s_Event = LuaManger.GetTable("GlobeEvent");
                s_DispatchEvent = s_Event.GetLuaFunction("Fire");
            }

            return s_DispatchEvent;
        }
    }

    /// <summary>
    /// 向Lua监听发送事件
    /// </summary>
    /// <param name="eventId"></param>
    /// <param name="value"></param>
    public static void DispatchEvent(int eventId, object value = null)
    {
        dispatchEvent?.Call(s_Event, eventId, value);
    }

    /// <summary>
    /// 向Lua监听发送事件
    /// </summary>
    /// <param name="eventId"></param>
    /// <param name="value"></param>
    public static void DispatchEvent(string eventId, object value = null)
    {
        dispatchEvent?.Call(s_Event, eventId, value);
    }

    /// <summary>
    /// 向Lua监听发送事件
    /// </summary>
    /// <param name="args"></param>
    //public static void DispatchEvent(params object[] args)
    //{
    //    Debug.Log($"DispatchEvent eventId  is params:{args}");
    //    dispatchEvent?.Call(s_Event, args);
    //}

}